<?php

class Mod_User extends CI_Model{
	public function getUserById($id){
		$this->db->select('*')->where(field('id'), $id);
		$result = $this->db->get(table('user'));
		$result = $result->result_array();
		return $result[0];
	}
	
	public function update($id, $fullName, $email, $password){
		$data = array(
			field('fullName') => $fullName,
			field('email')	  => $email,
			field('password') => sha1($password)
		);
		if(empty($password)) unset($data[field('password')]);
		
		$this->db->where(field('id'), $id);
		$result = $this->db->update(table('user'), $data);
		return $this->db->affected_rows($result);
	}
}